package com.bos.mapper;

import com.bos.data.model.BosProjectModel;
import com.bos.data.model.BosUserModel;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserMapper {
    //用户注册
    @Insert("insert into bos_user(name,password,sex,mobile,power) values(#{name},#{password},#{sex},#{mobile},#{power})")
    public int register(BosUserModel user);

    //用户登录
    @Select("select * from bos_user where name = #{name} and password = #{password}")
    public BosUserModel login(BosUserModel user);

    //3.将用户信息保存到数据库表bos_user中
    @Insert("insert into bos_user(userId,name,password,mobile,power,department,email,position,gender,status,entryTime) values(#{userId},#{name},#{password},#{mobile},#{power},#{department},#{email},#{position},#{gender},#{status},#{entryTime})")
    public int insertUser(BosUserModel user);

    //4.成员扫描登录时，根据登录成员ID查询成员角色和成员角色对应的功能节点列表，并查询功能节点列表对应的权限列表信息，将功能节点信息返回到页面上，
    //--根据登陆成员Id(userId) 查询成员角色
    @Select("select * from bos_user u,bos_role r,bos_role_node rn,bos_node n,bos_user_role ur where u.userId=ur.userId and ur.roleId=r.roleId and r.roleId=rn.roleId and m.nodeId=n.nodeId")
    public List<BosUserModel> findUser();


    //5.根据名字查询出bos_user中的数据
    @Select("select * from bos_user where name=#{name}")
    public BosUserModel findUserByName(String name);

    //6.根据名字查询出bos_Project中的数据
    @Select("select * from bos_project where leader=#{leader}")
    public List<BosProjectModel> findProjectByName(String name);

    //7.查询出Bos_user表中的数据
    @Select("select * from bos_user")
    public List<BosUserModel> findUsers();
}
